package com.ejior.bluetea.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 存储蓝牙设备的信息
 */

public class BLEDevice implements Parcelable {

    private String deviceName;

    private String mac;

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.deviceName);
        dest.writeString(this.mac);
    }

    public BLEDevice() {
    }

    protected BLEDevice(Parcel in) {
        this.deviceName = in.readString();
        this.mac = in.readString();
    }

    public static final Parcelable.Creator<BLEDevice> CREATOR = new Parcelable.Creator<BLEDevice>() {
        @Override
        public BLEDevice createFromParcel(Parcel source) {
            return new BLEDevice(source);
        }

        @Override
        public BLEDevice[] newArray(int size) {
            return new BLEDevice[size];
        }
    };

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BLEDevice bleDevice = (BLEDevice) o;

        if (!deviceName.equals(bleDevice.deviceName)) return false;
        return mac.equals(bleDevice.mac);

    }

    @Override
    public int hashCode() {
        int result = deviceName.hashCode();
        result = 31 * result + mac.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "BLEDevice{" +
                "deviceName='" + deviceName + '\'' +
                ", mac='" + mac + '\'' +
                '}';
    }
}
